home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
TECHNICA
/
AUTOCAD
/
H108.ZIP
/
SETPORT.ZIP
/
SETPORT.LSP
< prev
Wrap
Lisp/Scheme
|
1991-09-29
|
3KB
|
97 lines
; This routine will take a lot of the grief out of creating,sizing
; and displaying viewports in pspace. Many thanks to John Barton
; for adding the ability to drag a box around when placing the viewport.
;
; Gary Kessel
; 901-526-9600
; 76447,1020
;
(defun c:SETPORT ()
(setvar "tilemode" 1)
;get world coordinates
(setq ll (getpoint "\nPick lower left corner: ")
ur (getcorner "\nPick upper right corner: " ll ))
(setq x1 (car ll))
(setq y1 (cadr ll))
(setq x2 (car ur))
(setq y2 (cadr ur))
; calc "real world" port size
(setq xdist (abs(- x1 x2)))
(setq ydist (abs(- y1 y2)))
; get scale expressed as : 12 24 48 96 192 etc.
(setq vscale (getreal "\nScale for this view ?\n"))
; calc pspace port size
(setq xpdist (/ xdist vscale))
(setq ypdist (/ ydist vscale))
; calc inverse of scale
(setq vscale (/ 1 vscale))
; get port name for recall and open .vpt file for saving info
(setq vname (strcat (getstring "\nName for this view ?\n") ".vpt"))
(setq file (open vname "w"))
; write info to file and close
(write-line (rtos xpdist 2 10) file)
(write-line (rtos ypdist 2 10) file)
(write-line (rtos vscale 2 10) file)
(princ ll file)
(princ "\n" file)
(princ ur file)
(close file)
)
;
; The routine for recalling the port simply reads in the file info and
; goes through a sequence that you might do manually.
;
(defun c:GETPORT ()
(setq file (getstring "\nViewport to get ?\n"))
(setq file2 (open (strcat file ".vpt") "r"))
(setq xpdist (atof(read-line file2)))
(setq ypdist (atof(read-line file2)))
(setq vscale (atof(read-line file2)))
(setq ll (read-line file2))
(setq ll (read ll))
(setq ur (read-line file2))
(setq ur (read ur))
(close file2)
(setvar "tilemode" 0)
(command "pspace")
(setq start (setpoint ))
(command "mview" start (list (+ (car start) xpdist) (+ (cadr start) ypdist)))
(command "mspace")
(command "zoom" "w" ll ur)
(command "zoom" (strcat (rtos vscale 2 10) "xp"))
(command "pspace")
)
; This is the routine for dragging a box around while placing the port in
; pspace. The pick is a little sluggish at times but it will work.
;
(defun grbox(ptx /)
(grdraw ptx (setq pt2 (polar ptx 0 xpdist)) -1)
(grdraw pt2 (setq pt3 (polar pt2 (* 0.5 pi) ypdist)) -1)
(grdraw pt3 (setq pt4 (polar ptx (* 0.5 pi) ypdist)) -1)
(grdraw pt4 ptx -1)
)
(defun setpoint ()
(prompt "\nPick point for lower left corner:\n")
(setq done 1)
(setq ptb (cadr (grread T)))
(grbox ptb)
(while done
(setq glist (grread T))
(setq pta ptb)
(setq ptb (cadr (grread T)))
(if (and (= (car glist) 5) (> (distance pta ptb) 0.03))
(progn
(grbox pta)
(grbox ptb)
)
)
(if (= (car glist) 3)
(progn
(setq done nil)
(grbox pta)
(setq pt (cadr glist))
)
)
)
)